Fix ModNote.fromProto to map modActionData to modAction#269
Open
hsource wants to merge 4 commits into
Open
Conversation
reddit.getModNotes() already receives modActionData from the Reddit API, but #fromProto never populated modAction on the returned ModNote objects. Map action, details, description, and target redditId so callers can read ban/removal/approval metadata without bypassing the client. Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce a focused ModNoteAction type instead of reusing ModAction, and map modActionData inline in fromProto with typed redditId conversion. Co-authored-by: Cursor <cursoragent@cursor.com>
Explain that mod notes and moderation log entries are distinct use cases with overlapping context already on ModNote. Co-authored-by: Cursor <cursoragent@cursor.com>
Restore the original UserNote shape, userNote optional typing, and inline createdAt conversion. Co-authored-by: Cursor <cursoragent@cursor.com>
stephenoid
reviewed
Jun 22, 2026
stephenoid
left a comment
Member
There was a problem hiding this comment.
thank you for the patch! please see feedback inline.
|
|
||
| /** | ||
| * Action metadata from a mod note's `modActionData`. Kept separate from | ||
| * {@link ModAction} to reduce field duplication — mod notes and moderation |
Member
There was a problem hiding this comment.
my concern with adding a new type is that it will be a breaking change for existing usages. in light of this, what do you think about extending ModAction like:
export type ModNoteAction = ModAction & {
action: ModActionType;
/** The ID of the thing being moderated. */
redditId?: T1ID | T2ID | T3ID | undefined;
}or even just adding the fields as optional to ModAction?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
While writing a moderation app that auto-applies escalating bans, I realized that the modAction wasn't actually being converted from the proto.
In my app, I worked around this by directly calling
getDevvitConfig().use(ModNoteDefinition);, which is a bit of a hack, so I wanted to resolve this more permanently with this upstream PR.Changes
ModNoteAction— a focused type withaction,redditId,details, anddescription— instead of reusing the fullModActiontypemodActionDatainline inModNote.#fromProtofor both@devvit/redditand@devvit/public-apiredditIdwith typed ID helpers (asTID/asTid) forT1/T2/T3fullnamesdetailsanddescriptionforbanuseractions (duration like"1 days", ban reasoning)modActionshapeTesting
I couldn't really test this unfortunately since the root README.md instructions failed at the point I tried to
yarnto install, since there were many Reddit-internal packages whose installs didn't work even after I disabled artifactory. I did do a thorough self-review of the PR though and its logic looks pretty simpleyarn workspace @devvit/reddit test:unit—getModNotes() maps modActionData to modActiontestyarn workspace @devvit/public-api test:unit— same test in public-api packagereddit.getModNotes({ subreddit, user, filter: 'MOD_ACTION' })and verify ban notes includemodAction.detailsandmodAction.description